package com.ruoyi.manage.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.UUIDUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.manage.mapper.InvitationCodeMapper;
import com.ruoyi.manage.domain.InvitationCode;
import com.ruoyi.manage.service.IInvitationCodeService;

/**
 * 邀请码Service业务层处理
 * 
 * @author zzg
 * @date 2025-03-20
 */
@Service
public class InvitationCodeServiceImpl implements IInvitationCodeService 
{
    @Autowired
    private InvitationCodeMapper invitationCodeMapper;

    /**
     * 查询邀请码
     * 
     * @param id 邀请码主键
     * @return 邀请码
     */
    @Override
    public InvitationCode selectInvitationCodeById(Long id)
    {
        return invitationCodeMapper.selectInvitationCodeById(id);
    }

    /**
     * 查询邀请码列表
     * 
     * @param invitationCode 邀请码
     * @return 邀请码
     */
    @Override
    public List<InvitationCode> selectInvitationCodeList(InvitationCode invitationCode)
    {
        return invitationCodeMapper.selectInvitationCodeList(invitationCode);
    }

    /**
     * 新增邀请码
     * 
     * @param invitationCode 邀请码
     * @return 结果
     */
    @Override
    public int insertInvitationCode(InvitationCode invitationCode)
    {
        invitationCode.setCode(UUIDUtils.getUUID());
        invitationCode.setStatus(0);
        invitationCode.setCreateTime(DateUtils.getNowDate());
        return invitationCodeMapper.insertInvitationCode(invitationCode);
    }

    /**
     * 修改邀请码
     * 
     * @param invitationCode 邀请码
     * @return 结果
     */
    @Override
    public int updateInvitationCode(InvitationCode invitationCode)
    {
        return invitationCodeMapper.updateInvitationCode(invitationCode);
    }

    /**
     * 批量删除邀请码
     * 
     * @param ids 需要删除的邀请码主键
     * @return 结果
     */
    @Override
    public int deleteInvitationCodeByIds(Long[] ids)
    {
        return invitationCodeMapper.deleteInvitationCodeByIds(ids);
    }

    /**
     * 删除邀请码信息
     * 
     * @param id 邀请码主键
     * @return 结果
     */
    @Override
    public int deleteInvitationCodeById(Long id)
    {
        return invitationCodeMapper.deleteInvitationCodeById(id);
    }
}
